#include <iostream>
using std::cout;
using std::endl;

class Base{
public:
    Base(long x)
    : _base(x)
    {}

    void display() const{
        cout << "Base::display()" << endl;
    }
    void func1(){
        cout << "func1()" << endl;
    }
private:
    long _base;
};


class Derived
: public Base
{
public:
    Derived(long base,long derived)
    : Base(base)
    , _derived(derived)
    {}

    void display() const{
        cout << "Derived::display()" << endl;
    }

    void func2(){
        cout << "func2()" << endl;
    }
private:
    long _derived;

};

void test0(){
    Derived d1(4,9);
    Derived * pderived = &d1;
    pderived->func1();
    pderived->func2();
    pderived->display();

    //基类指针指向派生类对象，只能访问基类子对象的内容
    Base * pbase = &d1;
    pbase->func1();
    /* pbase->func2(); */
    pbase->display();
}

int main(void){
    test0();
    return 0;
}
